<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('查询快递')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">供应商</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="cys"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">运单号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="ysdh"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">订单号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="fybh"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">收货地址</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="dz"/>
                        </div>
                    </div>

                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload">搜索</a>
                    </div>

                    <div class="moreSearch" style="display: none">

                        <div class="layui-inline">
                            <label class="layui-form-label">用途</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="yt"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">收货方式</label>
                            <select name="jhfs" lay-filter="aihao">
                                <option value="">全部</option>
                                <option value="0">发运</option>
                                <option value="1">自提</option>
                                <option value="2">到付</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">承运方式</label>
                            <select name="cyslb" lay-filter="aihao">
                                <option value="">全部</option>
                                <option value="0">初始</option>
                                <option value="1">快递</option>
                                <option value="2">物流</option>
                                <option value="3">申通快递</option>
                                <option value="4">到付</option>
                                <option value="5">自提</option>
                            </select>
                        </div>
                    </div>
                </form>

               <!-- <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
                <div class="group-button" id="toolbar">
                    <a class="layui-btn layui-btn-sm layui-btn-normal  out-put" >
                        <i class="layui-icon">&#x1005;</i> 导出
                    </a>
                </div>

                &lt;!&ndash;列表&ndash;&gt;
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>-->


                <div class="group-button tpl-button" id="toolbar">
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table"></table>
                    </div>
                </section>

            </div>
        </div>
    </div>
</div>
</body>


<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script th:inline="javascript">
    $("form input[type=text]").each(function () {
        this.value = $.trim(this.value);

        $(document).ready(function () {//通用方法去输入框前后空格
            $("form").on("change", function () {
                $("form input[type=text]").each(function () {
                    this.value = $.trim(this.value);
                });
            })
        });
    });

    console.log("我来了！！ ");
    $(".moreBtn").on("click",function () {
        $(".moreSearch").toggle();
    })

    var functions = [[${functions}]];
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {
        /*var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.select2({
            elem: ".js-data-example-ajax",
            url: "/wmsrrailwayplatform/list"
        });
        */

        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        var $table;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                exportEvent: function(data){
                    var arr=[];
                    var $rows = $table.bootstrapTable('getSelections');
                    if ($rows.length >0) {
                        arr = $.map($rows, function (row) {
                            return row.id;
                        })
                    }
                    /*
                     * 以下是将ids和对象拼接在一起
                     * */
                    var str=zzpUtils.getFormJson($("#searchForm"));
                    var object2 = Object.assign({ids: arr}, str);
                    /*将条件查询和ids传到后台*/
                    zzpUtils.outputXslx({
                        url:"/statistics/seachWlkdExport",
                        data:JSON.stringify(object2)
                    });
                }
            }
        });




        /*window.operateEvent = {
            "click .layui-btn-primary": function (e, value, row, index) {
                alert(row.mc);
            },
            "click #check": function (e, value, row, index) {//删除
                checkDialog(row.ysdh);
            }
        };*/

        /*/!*顶部按钮导出 *!/
        $(".out-put").on('click', function () {
            var arr=[];
            var $rows = $table.bootstrapTable('getSelections');
            if ($rows.length >0) {
                arr = $.map($rows, function (row) {
                    return row.ysdh;
                })
            }
            var xhr = new XMLHttpRequest();
            xhr.open("POST", "http://localhost:8080/zxsdwms/statistics/seachWlkdExport", true);
            xhr.responseType = "blob";
            xhr.setRequestHeader('Accept', 'application/json');
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.setRequestHeader('Charset', 'utf-8');
            xhr.onload = function() {
                if (this.status == 200) {
                    var name = xhr.getResponseHeader("Content-disposition");
                    name=decodeURI(name);
                    var filename = name.substring(20,name.length);
                    var blob = new Blob([xhr.response], {type: 'text/xls'});
                    var csvUrl = URL.createObjectURL(blob);
                    var link = document.createElement('a');
                    link.href = csvUrl;
                    link.download = filename;
                    link.click();
                }
            };
            /!*
            * 以下是将ids和对象拼接在一起
            * *!/
            var obj = [];
            for(var i=0;i<arr.length;i++) {
                var person = {};
                person[i] = arr[i];
                obj.push(person);
            }
            var str=zzpUtils.getFormJson($("#searchForm"));
            var object2 = Object.assign({ids: arr}, str);
            /!*将条件查询和ids传到后台*!/
            xhr.send(JSON.stringify(
                object2
            ));
        })//导出结束*/


       /* /!*顶部按钮多选启用*!/
        $("#btn_qi").on('click', function () {
            var index = 0;
            var $rows = $table.bootstrapTable('getSelections');
            //判断选中的库区里是否有已经启用的
            for (var i = 0; i < $rows.length; i++) {
                if ($rows[i].jhzt == 1) {
                    index++;
                }
            }
        })*/

        laydate.render({
            elem: '#test5'
            , theme: '#20a0ff'
        });
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
            url: '/statistics/seachWlkd',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'show_cyslb',
                title: '承运方式'
            }, {
                field: 'cys',
                title: '承运商'
            }, {
                field: 'ysdh',
                title: '运单号'
            }, {
                field: 'fybh',
                title: '订单号'
            }, {
                field: 'fysj',
                title: '发货日期'
            }, {
                field: 'zfrq',
                title: '支付日期'
            }, {
                field: 'yiji',
                title: '一级'
            }, {
                field: 'erji',
                title: '二级'
            }, {
                field: 'sanji',
                title: '三级'
            }, {
                field: 'yt',
                title: '用途'
            }, {
                field: 'ddfqr',
                title: '发起人'
            }, {
                field: 'fqbm',
                title: '发起部门'
            },{
                field: 'shrxm',
                title: '收货人姓名'
            }, {
                field: 'gj',
                title: '国家'
            }, {
                field: 'sheng',
                title: '省份'
            }, {
                field: 'shi',
                title: '城市'
            }, {
                field: 'xq',
                title: '县区'
            }, {
                field: 'dz',
                title: '收货地址'
            },  {
                field: 'show_jhfs',
                title: '收货方式'
            },{
                field: 'lxrdh',
                title: '电话'
            }, {
                field: 'cphz',
                title: '产品汇总'
            }, {
                field: 'ysxs',
                title: '发运箱数'
            }, {
                field: 'llzl',
                title: '理论重量'
            },{
                field: 'sjzl',
                title: '实际重量'
            },{
                field: 'yf',
                title: '运费'
            },{
                field: 'yfcdf',
                title: '运费承担方'
            },{
                field: 'dwbj',
                title: '对外物流报价'
            },{
                field: 'bz',
                title: '备注'
            }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
        });

        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })
    });
</script>
</html>